<?php

/**
 * LoginForm class.
 * LoginForm is the data structure for keeping
 * user login form data. It is used by the 'login' action of 'SiteController'.
 */
class ChangePassForm extends CFormModel
{
    public $password;
    public $oldPassword;//旧密码

    public function rules()
    {
        return array(
            array('oldPassword', 'required','message' => '请输入旧密码'),
            array('password','length','is' => 32,'message'=>'密码长度不对'),
            array('password','checkPassword','skipOnError'=>true),
        );
    }

    /**
     * Declares attribute labels.
     */
    public function attributeLabels()
    {
        return array(
            'password' => '密码',
       );
    }

    /**
     * 校验密码是否过于简单
     */
    public function checkPassword()
    {
        if(Helper::checkIsSimplePass($this->password))
            $this->addError('password','密码过于简单，请使用安全系数更高的密码');
    }
}
